package com.social.serviceImpl;

import com.social.dao.RoleMapper;
import com.social.pojo.Role;
import com.social.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<Role> selectAll() {
        List<Role> roles = roleMapper.selectAll();
        return roles;
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        int status = roleMapper.deleteByPrimaryKey(id);
        return status;
    }

    @Override
    public int insert(Role record) {
        int status = roleMapper.insert(record);
        return status;
    }

    @Override
    public int insertSelective(Role record) {
        int status = roleMapper.insertSelective(record);
        return status;
    }

    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    @Override
    public Role selectByPrimaryKey(Integer id) {
        Role role = roleMapper.selectByPrimaryKey(id);
        return role;
    }

    @Override
    public Role selectByUserId(Integer id) {
        Role role = roleMapper.selectByUserId(id);
        return role;
    }

    @Override
    public int updateByPrimaryKeySelective(Role record) {
        int status = roleMapper.updateByPrimaryKeySelective(record);
        return status;
    }

    @Override
    public int updateByPrimaryKey(Role record) {
        int status = roleMapper.updateByPrimaryKey(record);
        return status;
    }
}